package actor.persistencefsm

/**
 * Created by DJJ on 2020/1/3.
 */
package persistentfsm.demo
import persistentfsm.cart._
import persistentfsm.tracker._
import akka.actor._
import WebShopping._
import com.typesafe.config.ConfigFactory

object PersistentFSMDemo extends App {
  val pfSystem = ActorSystem("persistentfsm-system",ConfigFactory.load("persistenceFSM"))
  val trackerActor = pfSystem.actorOf(EventTracker.props,"tracker")
  val cart123 = pfSystem.actorOf(WebShopping.props("123"))

  cart123 ! GetCart
  cart123 ! AddItem(Item("001","Cigar",12.50))
  cart123 ! AddItem(Item("002","Wine",18.30))
  cart123 ! AddItem(Item("003","Coffee",5.50))
  cart123 ! GetCart
  cart123 ! RemoveItem("001")
  cart123 ! Buy
  cart123 ! GetCart
  cart123 ! AddItem(Item("004","Bread",3.25))
  cart123 ! AddItem(Item("005","Cake",5.25))



  scala.io.StdIn.readLine()

  pfSystem.terminate()

}
